package com.yl.ydk.ui.activity

import android.content.Intent
import android.view.View
import androidx.recyclerview.widget.RecyclerView
import androidx.viewpager.widget.ViewPager
import com.yl.ydk.R
import com.yl.ydk.base.BaseActivity
import com.yl.ydk.presenter.contract.DiseaseCateActivityContract
import com.yl.ydk.presenter.impl.DiseaseCateActivityImpl
import com.blankj.utilcode.utils.ToastUtils
import kotlinx.android.synthetic.main.activity_disease_cate.*
import kotlinx.android.synthetic.main.roob_bar.*
import q.rorbin.verticaltablayout.VerticalTabLayout

class DiseaseCateActivity : BaseActivity(), View.OnClickListener, DiseaseCateActivityContract.View {

    private val mPresenter = DiseaseCateActivityImpl()

    companion object {
        var diseaseCateActivity: DiseaseCateActivity? = null
    }


    override fun getLayoutId(): Int = R.layout.activity_disease_cate

    override fun attachView() {
        mPresenter.attachView(this)
    }

    override fun detachView() {
        mPresenter.detachView()
    }

    override fun initView() {
        tvTitle.text = "常见疾病"
        rlSearch.visibility = View.VISIBLE
        rlBack.setOnClickListener(this)
        rlSearch.setOnClickListener(this)
        mPresenter.getHealthGDiseaseCate(this)
        diseaseCateActivity = this

    }

    override fun onClick(v: View?) {
        when (v?.id) {
            R.id.rlBack -> {
                finish()
            }
            R.id.rlSearch -> {
                startActivityIn(Intent(this,DiseaseSearchActivity::class.java),this)
            }
        }
    }

    override fun onDestroy() {
        super.onDestroy()
        diseaseCateActivity = null
    }

    override fun getViewPager(): ViewPager? = vp

    override fun getVerticalTabLayout(): VerticalTabLayout? = tabLayout

    override fun getRecyclerView(): RecyclerView?  = rvDiseases

    override fun getActivity(): DiseaseCateActivity = this

    override fun showError(message: String?) {
        ToastUtils.showLongToastSafe(message)
    }

}